﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TinyROS
{
    namespace Exceptions
    {
        public class TinyROSException : Exception
        { 
            public TinyROSException()
            {

            }
            public TinyROSException(string msg) : base(msg)
            {

            }
        }
        public class NodeException : TinyROSException
        {
            public NodeException()
            {

            }
            public NodeException(string msg) : base(msg)
            {

            }
        }
        public class TopicException : TinyROSException
        {
            public TopicException()
            {

            }
            public TopicException(string msg) : base(msg)
            {

            }
        }
        public class MessageException : TinyROSException
        {
            public MessageException()
            {

            }
            public MessageException(string msg) : base(msg)
            {

            }
        }

        public class CoreException : TinyROSException
        {
            public CoreException()
            {

            }
            public CoreException(string msg) : base(msg)
            {

            }
        }
        public class TopicNotExistException : CoreException
        {
            public TopicNotExistException() : base("Topic does not exist.")
            {

            }
            public TopicNotExistException(string topicName) : base($"Topic does not exist:{topicName}")
            {

            }
        }
        public class NodeNotInitedException : NodeException
        {
            public NodeNotInitedException() : base("This node is not initialized.")
            {

            }
        }
        public class MessageTypeException : TopicException
        {
            public MessageTypeException() : base("Published message type does not match this topic.")
            {

            }
            public MessageTypeException(string expected)
                : base($"Published message type does not match this topic, expected: {expected}.")
            {

            }
        }
        public class MessageConstructFailedException : MessageException
        {
            public MessageConstructFailedException()
            {

            }
            public MessageConstructFailedException(string msg) : base(msg)
            {

            }
        }
        public class NodeInitFailedExcepiton : NodeException
        {
            public NodeInitFailedExcepiton() : base("node init failed")
            {

            }
            public NodeInitFailedExcepiton(string nodeName) : base($"node {nodeName} init failed")
            {

            }
        }
        public class CommandExecuteException : CoreException
        {
            public CommandExecuteException()
            {

            }
            public CommandExecuteException(string msg) : base(msg)
            {

            }
        }
        public class CommandParseException : CoreException
        {
            public string Command { get; }
            public CommandParseException()
            {
                this.Command = string.Empty;
            }
            public CommandParseException(string cmd)
            {
                this.Command = cmd;
            }
        }
        public class CommandNotFoundException : CommandParseException
        { 
            public string UnfoundCommand { get; }
            public CommandNotFoundException() 
            { 
            
            }
            public CommandNotFoundException(string cmd) : base(cmd)
            {
                this.UnfoundCommand = cmd;
            }
        }
        public class CommandArgumentExcepiton : CommandParseException
        {
            public CommandArgumentExcepiton()
            {

            }
            public CommandArgumentExcepiton(string cmd) : base(cmd)
            {

            }
        }
        public class InvalidArgumentException : CommandArgumentExcepiton
        {
            public string Arg { get; }
            public InvalidArgumentException()
            {

            }
            public InvalidArgumentException(string cmd, string arg): base(cmd)
            {
                this.Arg = arg;
            }
        }
        public class ArgumentCountException : CommandArgumentExcepiton
        {
            public ArgumentCountException()
            {

            }
            public ArgumentCountException(string cmd) : base(cmd)
            {

            }
        }
        public class NodeTypeNotFoundException : CommandExecuteException
        {
            public string NodeTypeName { get; }
            public NodeTypeNotFoundException()
            {

            }
            public NodeTypeNotFoundException(string nodeTypeName) : base($"Could not find node type named {nodeTypeName}")
            {
                this.NodeTypeName = nodeTypeName;
            }
        }
        public class TopicTypeNotFoundException : CommandExecuteException
        {
            public string TopicTypeName { get; }
            public TopicTypeNotFoundException()
            {

            }
            public TopicTypeNotFoundException(string topicTypeName) : base($"Could not find node type named {topicTypeName}")
            {
                this.TopicTypeName = topicTypeName;
            }
        }

        public class NodeNotExistExecption : CoreException
        {
            public NodeNotExistExecption() : base("Node does not exist.")
            {

            }
            public NodeNotExistExecption(string nodeName) : base($"Node does not exist:{nodeName}")
            {

            }
        }
        public class NodeInstanceCreateFailedException : CommandExecuteException
        {
            public NodeInstanceCreateFailedException()
            {

            }
            public NodeInstanceCreateFailedException(string msg) : base(msg)
            {

            }
        }
        public class TopicInstanceCreateFailedExcepiton : CommandExecuteException
        {
            public TopicInstanceCreateFailedExcepiton()
            {

            }
            public TopicInstanceCreateFailedExcepiton(string msg) : base(msg)
            {

            }
        }

        public class NodeMethodException : NodeException
        {
            public NodeMethodException()
            {

            }
            public NodeMethodException(string s) : base(s)
            {

            }
        }
        public class NotEnoughForPlanningException : NodeMethodException
        {
            public NotEnoughForPlanningException(string s) : base(s)
            {

            }
        }
        public class PathNotFoundException : NodeMethodException
        {
            public PathNotFoundException() : base("could not find a path from start to goal")
            {

            }
        }
        public class NotEnoughForPrintException : NodeMethodException
        {
            public NotEnoughForPrintException() : base("missing path or map to print")
            {

            }
        }
        public class NodeDisposeExcepiton : NodeException
        {
            public NodeDisposeExcepiton()
            {

            }
            public NodeDisposeExcepiton(string msg) : base (msg)
            {

            }
        }
        public class SerialPortInitException : NodeMethodException
        {
            public SerialPortInitException()
            { 

            }
            public SerialPortInitException(string msg) : base(msg)
            {

            }
        }
        public class AlreadyExistException : CoreException
        {
            public string ExistedName { get; } = string.Empty;
            public AlreadyExistException()
            {

            }
            public AlreadyExistException(string msg)  : base(msg)
            {
                this.ExistedName = msg;
            }
        }
        
        public class NodeNotSupportCommandException : NodeException
        {
            public NodeNotSupportCommandException()
            {

            }
            public NodeNotSupportCommandException(string msg) :base(msg)
            {

            }
        }
        public class LoadAssemblyFailedException : CommandExecuteException
        {
            public LoadAssemblyFailedException()
            {

            }
            public LoadAssemblyFailedException(string msg) : base(msg)
            {

            }
        }


    }

}
